package com.zero.controller;

import com.zero.entity.Result;
import com.zero.service.StorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/storage")
public class StorageController {

    @Autowired
    private StorageService storageService;

    /**
     * 扣除库存
     * @param goodsId 商品id
     * @param count 扣除数量
     * @return 库存扣除结果
     */
    @RequestMapping("/deduct/{goodsId}/{count}")
    public Result deductStorage(@PathVariable("goodsId") int goodsId, @PathVariable("count") int count) {
        return storageService.deductStorage(goodsId, count);
    }
}
